<?php
class FolioImage extends DataObject{
	
	public static $db = array(
		'Title' => 'Varchar(255)'
	);

	public static $has_one = array(
		'FolioImage'  	=> 'Image',
		'Parent' 		=> 'Page'
	);

	public static $extensions = array(
		'Orderable'
	);

	public static $summary_fields = array(
		'Title'            => 'Title',
		'SummaryThumbnail' => 'Image'
	);
	
	public function getCMSFields() {
		$fields = parent::getCMSFields();

		if (!$this->isInDB()) {
			$fields->replaceField('FolioImage', new SimpleImageField('FolioImage'));
		}

		return $fields;
	}
	
	public function SummaryThumbnail() {
		return ($i = $this->FolioImage()) ? $i->SetHeight(50) : '(No image)';
	}
}